package com.pwt.repository;

import com.pwt.repository.base.BaseRepository;
import com.pwt.entity.ZzWatchCharts;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

/**
 * ZzWatchCharts Repository层
 *
 * @author auto generated
 * @date 2021-10-13 17:26:23
 */
public interface ZzWatchChartsRepository extends BaseRepository<ZzWatchCharts, String>,ZzWatchChartsRepositoryExtension{

    @Query(nativeQuery = true,value = "SELECT count(1) from zz_watch_charts where (RIGHT_STATUS='OK' or RIGHT_STATUS='SOMEOK') and K0010= ?1 and K0004>=?2 and K0004<=?3")
    Integer queryZzWatchChartsByOk(Integer k0010, Date startTime,Date endTime);

    @Query(nativeQuery = true,value = "SELECT count(1) from zz_watch_charts where (RIGHT_STATUS='NOK' or RIGHT_STATUS='BAD') and K0010= ?1 and K0004>=?2 and K0004<=?3")
    Integer queryZzWatchChartsByNok(Integer k0010, Date startTime,Date endTime);

    @Query(nativeQuery = true,value = "SELECT count(1) from zz_watch_charts where RIGHT_STATUS='BAD' and K0010= ?1 and K0004>=?2 and K0004<=?3")
    Integer queryZzWatchChartsByBad(Integer k0010, Date startTime,Date endTime);

    @Query(nativeQuery = true,value = "SELECT  top 1 K1002 from zz_watch_charts where K0010= ?1 and  K0004<=?2 and K1002 is not null")
    String queryZzWatchChartsByK0010(Integer k0010,Date endTime);

    @Query(nativeQuery = true,value = "select * from zz_watch_charts where k0010=?0 and k0014=?1 and k0004=?2")
    ZzWatchCharts queryByK0010AndK0014AndK0004(Integer k0010,String k0014,Date k0004);

}
